<!--{template /module/admin/view/head}-->
<div id="left_layout">
	<div id="main_content" class="container-fluid">
		<!--{template /module/admin/view/head_nav}-->
		<div class="row-fluid">
			<div class="well widget">
				<div class="widget-header">
					<h3 class="title">{lang cms.subject.view.header}</h3>
				</div>
				<div class="widget-content">
					<form class="form-search" id="frm_search" name="frmSearch" action="{$ADMIN_SCRIPT}/cms/subject" method="post">
					<div class="action-wrapper">
						<div class="pull-left">
							<a href="javascript:void(null);" id="btn_pass_list" class="btn btn-small" {$dispatches[operations][audit]}>{lang admin.operation.pass}</a>
							<a href="javascript:void(null);" id="btn_fail_list" class="btn btn-small" {$dispatches[operations][audit]}>{lang admin.operation.fail}</a>
							<a href="javascript:void(null);" id="btn_delete_list" class="btn btn-small" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
							<a href="{$ADMIN_SCRIPT}/cms/subject/_pub" {$dispatches[operations][add]} class="btn btn-small">{lang cms.subject.view.operation.add}</a>
						</div>
						<div class="pull-right" {$dispatches[operations][search]}>
							<div class="input-append">
								<input type="text" name="txtKeyword" value="{$_var[gp_txtKeyword]}" class="input-small search-query" />
								<button type="submit" class="btn">{lang cms.subject.view.operation.search}</button>
							</div>
						</div>
					</div>
					</form>
					
					<hr/>
					<form id="frm_grid" name="frmGrid" action="{$ADMIN_SCRIPT}/cms/subject&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}" method="post">
					<table class="table table-hover">
						<thead>
							<tr>
								<th width="30"><input type="checkbox" class="fancy" name="cbxAll"/></th>
								<th width="80">{lang cms.subject.view.th.identity}</th>
					            <th>{lang cms.subject.view.th.title}</th>
					            <th width="120">{lang cms.subject.view.th.username}/{lang cms.subject.view.th.edittime}</th>
					            <th width="80">{lang cms.subject.view.th.istop}/{lang cms.subject.view.th.iscommend}</th>
					            <th width="50">{lang cms.subject.view.th.isaudit}</th>
					            <th width="90">{lang cms.subject.view.th.operation}</th>
							</tr>
						</thead>
						<tbody>
							<!--{loop $subjects $_loop $subject}-->
							<tr class="item-row">
							<td class="center">
				        		<input type="checkbox" class="fancy" name="cbxItem[]" title="{$subject[TITLE]}" value="{$subject[SUBJECTID]}"/>
				            </td>
				            <td class="center">
				            	{$subject[IDENTITY]}
				            </td>
				            <td class="left">
				            	<p class="thin">
					            	<a href="{$ADMIN_SCRIPT}/cms/subject/_view&id={$subject[SUBJECTID]}" title="{$subject[TITLE]}" class="{echo $subject['ISAUDIT'] == 1 ? 'text-success' : 'text-error';}">{$subject[TITLE]}</a>
					            </p>
					            <p class="muted thin">
					            	 {$subject[SUMMARY]}
					            </p>
				            </td>
				            <td class="f10">
					            {$subject[USERNAME]}<br/>
					            {$subject[EDITTIME]}
				            </td>
				            <td>
					            <!--{if $subject['ISTOP'] == 1}-->
					            <span class="text-success">{lang cms.subject.view.td.istop.yes}</span>
					            <!--{else}-->
					            <span class="muted">{lang cms.subject.view.td.istop.no}</span>
					            <!--{/if}-->
					            <br/>
					            <!--{if $subject['ISCOMMEND'] > 0}-->
					            <span class="text-success">{$subject[ISCOMMEND]}{lang cms.subject.view.td.iscommend.unit}</span>
					            <!--{else}-->
					            <span class="muted">{lang cms.subject.view.td.iscommend.no}</span>
					            <!--{/if}-->
				            </td>
				            <td>
					            <!--{if $subject['ISAUDIT'] == 1}-->
					            <span class="text-success">{lang cms.subject.view.td.isaudit.yes}</span>
					            <!--{else}-->
					            <span class="text-error">{lang cms.subject.view.td.isaudit.no}</span>
					            <!--{/if}-->
				            </td>
				            <td>
					            <a class="btn btn-mini btn-primary" href="{$ADMIN_SCRIPT}/cms/subject/_update&id={$subject[SUBJECTID]}&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}" {$dispatches[operations][edit]}>{lang admin.operation.edit}</a>
					            <a class="btn btn-mini btn-delete" title="{$subject[TITLE]}" data="{$subject[SUBJECTID]}" href="javascript:void(null);" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
				            </td>
				            </tr>
				            <!--{/loop}-->
				            <!--{if $count == 0}-->
					        <tr>
					            <td colspan="7">
					                * {lang admin.operation.empty}
					            </td>
					        </tr>
					        <!--{/if}-->
						</tbody>
					</table>
					</form>
					
					<hr/>
					{$pager}
				</div>
			</div>
		</div>
	</div>
</div>

<script>
$(function(){
	$('.fancy').uniform();
	$(".pull-right .input-medium").datepicker({format:'yyyy-mm-dd'});
	
	$('#btn_submit').click(function(){
		$('#frm_grid').submit();
	});
	
	$('#btn_pass_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title') + '； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.pass}', message:'<p>{lang cms.subject.view.operation.pass.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/cms/subject&do=pass_list&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang cms.subject.view.operation.empty}'});
	});
	
	$('#btn_fail_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title') + '； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.fail}', message:'<p>{lang cms.subject.view.operation.fail.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/cms/subject&do=fail_list&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang cms.subject.view.operation.empty}'});
	});
	
	$('#btn_delete_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title') + '； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang cms.subject.view.operation.delete.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/cms/subject&do=delete_list&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang cms.subject.view.operation.empty}'});
	});
	
	$("#frm_grid input[name='cbxAll']").click(function(){
		if(this.checked){
			$('#frm_grid .item-row').addClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', true).parent().addClass('checked');
		}else{
			$('#frm_grid .item-row').removeClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', false).parent().removeAttr('class');
		}
	});
	
	$("#frm_grid input[name='cbxItem[]']").click(function(){
		if(this.checked) $(this).parent().parent().parent().parent().addClass('warning');
		else $(this).parent().parent().parent().parent().removeClass('warning');
	});
	
	$('#frm_grid .btn-delete').click(function(){
		var subjectid = $(this).attr('data');
		var tempHTML = '<p>' + $(this).attr('title') + '； </p>';
		
		$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang cms.subject.view.operation.delete.message}</p>' + tempHTML, callback:function(){
			$('#modal_dialog .btn-primary').click(function(){
				$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/cms/subject&do=delete&id=' + subjectid + '&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}');
				$('#frm_grid').submit();
			});
		}});
	});
});
</script>
<!--{template /module/admin/view/foot}-->